package com.infocollect.project.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.infocollect.project.api.entity.TappActOperatePermissionEntity;
import com.infocollect.project.api.mapper.TappActOperatePermissionMapper;
import com.infocollect.project.api.service.ITappActOperatePermissionService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (TappActoperatepermission)表服务实现类
 *
 * @author makejava
 * @since 2019-12-25 10:32:28
 */
@Service("tappActoperatepermissionService")
public class TappActOperatePermissionServiceImpl extends ServiceImpl<TappActOperatePermissionMapper, TappActOperatePermissionEntity> implements ITappActOperatePermissionService {


    /**
     * 通过ID查询单条数据
     *
     * @param fid 主键
     * @return 实例对象
     */
    @Override
    public TappActOperatePermissionEntity queryById(Long fid) {
        return this.baseMapper.selectById(fid);
    }



    /**
     * 新增数据
     *
     * @param tappActoperatepermission 实例对象
     * @return 实例对象
     */
    @Override
    public TappActOperatePermissionEntity insert(TappActOperatePermissionEntity tappActoperatepermission) {
        this.baseMapper.insert(tappActoperatepermission);
        return tappActoperatepermission;
    }

    /**
     * 修改数据
     *
     * @param tappActoperatepermission 实例对象
     * @return 实例对象
     */
    @Override
    public TappActOperatePermissionEntity update(TappActOperatePermissionEntity tappActoperatepermission) {
        this.baseMapper.updateById(tappActoperatepermission);
        return this.queryById(tappActoperatepermission.getFid());
    }

    /**
     * 通过主键删除数据
     *
     * @param fid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long fid) {
        return this.baseMapper.deleteById(fid) > 0;
    }

    @Override
    public List<TappActOperatePermissionEntity> queryByActId(Long actId){
        QueryWrapper<TappActOperatePermissionEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("factid",actId);
        return baseMapper.selectList(queryWrapper);
    }

}